package master

import (
	"io/ioutil"
	"encoding/json"
)

type Config struct {
	ApiPort int `json:"apiPort"`
	ApiReadTimeout int `json:"apiReadTimeout"`
	ApiWriteTimeout int `json:"apiWriteTimeout"`
	EtcdDialTimeout int `json:"etcdDialTimeout"`
	EtcdEndpoints []string `json:"etcdEndpoints"`
	WebRoot string `json:"webRoot"`

}


var G_config *Config

func InitConfig(fileName string) (err error){
	var(
		fileContent []byte
		cfg Config
	)
	if fileContent,err= ioutil.ReadFile(fileName);err!=nil{
		return
	}

	if err =json.Unmarshal(fileContent,&cfg);err!=nil{
		return
	}

	G_config=&cfg
	return
}